package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleConfigService;
import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.comment.dtos.CommentManageDto;
import com.heima.model.comment.dtos.CommentStatusDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * ClassName: ArticleClient
 * Description:
 * date: 2023/8/10 0010 18:24
 *
 * @author zHan
 */
@RestController
@RequestMapping("/api/v1/article")
@Api(tags = "app端文章相关接口")
public class ArticleClient implements IArticleClient {

    @Autowired
    private ApArticleService apArticleService;

    @Autowired
    private ApArticleConfigService apArticleConfigService;

    /**
     * 保存app端相关文章
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/save")
    @ApiOperation("保存app端相关文章")
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {
        return apArticleService.saveArticle(dto);
    }

    /**
     * 查询文章配置
     *
     * @param articleId
     * @return
     */
    @Override
    @GetMapping("/getArticleConfig/{articleId}")
    public ResponseResult getArticleConfig(@PathVariable Long articleId) {
        return apArticleConfigService.getArticleConfig(articleId);
    }

    /**
     * 查询评论列表
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/getArticle")
    public ResponseResult findNewsComments(@RequestBody CommentManageDto dto) {
        return apArticleService.findNewsComments(dto);
    }

    /**
     * 修改文章配置
     *
     * @param dto
     * @return
     */
    @Override
    @PutMapping("/updateArticleConfig")
    public ResponseResult updateArticleConfig(@RequestBody CommentStatusDto dto) {
        return apArticleConfigService.updateArticleConfig(dto);
    }

    /**
     * 统计数量
     *
     * @param map
     * @return
     */
    @Override
    @PostMapping("/getNewsDimension")
    public ResponseResult getNewsDimension(@RequestBody Map<String, String> map) {
        return apArticleService.getNewsDimension(map);
    }

    /**
     * 查询统计内容
     *
     * @param map
     * @return
     */
    @Override
    @PostMapping("/getNewPage")
    public ResponseResult getNewPage(@RequestBody Map<String, String> map) {
        return apArticleService.getNewPage(map);
    }
}
